﻿using System;
using System.Collections.Generic;

namespace Topro.DataAccess.Impl
{
    using Topro.Entity.Query;
    using Topro.Entity.Table;
    using Topro.Libraries.Data;

    /// <summary>
    /// 异常数据接口实现
    /// </summary>
    public class DeviceExceptionCodeImpl : Base, IDeviceExceptionCode
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        public List<DeviceExceptionCode> GetList(DeviceExceptionCodeListQuery query)
        {
            var list = DBContext.Select<DeviceExceptionCode>("*").From("t_deviceexceptioncode");

            Action<string, string, object> setWhere = (@where, name, value) => list.AndWhere(@where).Parameter(name, value);

            //类型
            if (query.MachineCode.HasValue)
            {
                setWhere("MachineCode = @MachineCode", "MachineCode", query.MachineCode.Value);
            }

            return list.QueryMany();
        }
    }
}
